<template>
	<view class="home">
		<image class="top-bgc" :src="resourceUrl+'home-top-bgc.png'"></image>
		<!-- 	<view class="location">
			<image :src="resourceUrl+'home-location.png'" mode=""></image>
			<text class="text">{{enterpriseMsg.districtname}}</text>
		</view> -->
		<view class="enterprise-msg" v-if="usertype!=9">
			<view class="enterprise-name">企业名称：{{enterpriseMsg.customername}}</view>
			<view class="enterprise-loc">行政归属：{{enterpriseMsg.districtname}}</view>
			<view class="admin-name">环保管理员：{{enterpriseMsg.hbperson}}</view>
		</view>
		<view class="enterprise-msg" v-if="usertype==9">
			<view class="enterprise-name">大队：{{parentdepartmentname}}</view>
			<view class="enterprise-loc">中队：{{departmentname}}</view>
			<view class="admin-name">姓名：{{username}}</view>
		</view>
		<image class="icon" :src="resourceUrl+'home-bgc-icon.png'"></image>
		<view class="inform-title-wrap">
			<view class="inform-wrap" @click="jumpInform">
				<image class="inform-icon" :src="resourceUrl+'home-inform.png'" mode=""></image>
				<view class="line"></view>
				<image class="inform-now" :src="resourceUrl+'home-now.png'" mode=""></image>
				<text>最新定期报告提醒 </text>
				<image :src="resourceUrl+'arrowright.png'" class="right-arrow"></image>
			</view>
		</view>
		<view class="message-wrap">
			<!-- 加上一个srcroll 能够进行滚动 -->
			<scroll-view scroll-y="true" class="scroll-container" show-scrollbar="false">
				<view class="xxx">
					<view class="message-one" @click="jumpEnterprise">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/paiwuxuke.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">排污许可</text>
						</view>
					</view>
					<view class="message-one" @click="EnterprisesAntipollutionfacilities">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/shebeiguanli.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							{{ usertype === 9 ? '设备管理' : '污染防治设施' }}
						</view>
					</view>

					<!-- 固危废管理 -->
					<view class="message-one" v-if="usertype==9" @click="Solidhazardouswaste">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/guweifeiguangli.png" mode="" class="one">
							</image>
						</view>
						<view class="one-text">
							固危废管理
						</view>
					</view>
					<!-- enb固危废管理 -->
					<!-- 污染物总量核算 -->
					<view class="message-one" v-if="usertype==9" @click="Antipollutionfacilities">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/wuranwu.png" mode="" class="one"></image>
						</view>
						<view class="one-texts">
							污染物总量核算
						</view>
					</view>
					<!-- end污染物总量核算 -->

					<view class="message-one" @click="jumpWarning">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/yingjiguankong.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">应急管控</text>
						</view>
					</view>
					<!-- 任务派发 -->
					<view class="message-one" v-if="usertype==9" @click="Taskassignment">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/renwupifa.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							任务派发
						</view>
					</view>
					<!-- end任务派发 -->
					<view class="message-one" @click="Selftesting">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/ziixngjiance.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">自行监测</text>
						</view>
					</view>

					<view class="message-one" v-if="usertype!=9" @click="EnterpriseCorporateAgent">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/renwupiafa.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">企业代办</text>
						</view>
					</view>
					<view class="message-one" @click="jumpDialogue">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/qiyezixun.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">企业咨询</text>
						</view>
					</view>
					<view class="message-one" @click="argument">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/yianshuofa.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">以案说法</text>
						</view>
					</view>

					<view class="message-one" v-if="usertype==9">
						<view class="img">
							<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/shujutongji.png" mode="" class="one"></image>
						</view>
						<view class="one-text">
							<text class="text">数据统计</text>
						</view>
					</view>
					
				</view>
			</scroll-view>
		</view>
	</view>
</template>
<script setup>
	import {
		resourceUrl
	} from "../../request/config";
	import {
		onShow,
		onLoad
	} from "@dcloudio/uni-app"
	import {
		ref
	} from 'vue'
	import http from '../../request/index.js'

	let enterpriseMsg = ref({})
	let usertype = ref('')
	let parentdepartmentname = ref('')
	let departmentname = ref('')
	let username = ref('')
	onShow(() => {
		let uid = uni.getStorageSync('uid')
		parentdepartmentname.value = uni.getStorageSync('parentdepartmentname')
		departmentname.value = uni.getStorageSync('departmentname')
		username.value = uni.getStorageSync('username')
		http({
			url: "/enterprise/detail",
			data: {
				id: uid
			}
		}).then((res) => {
			if (res.code == 0) {
				enterpriseMsg.value = res.data
				uni.setStorageSync("enterprisemsg", JSON.stringify(res.data))
			}
		})
		let moban = JSON.parse(uni.getStorageSync('boban'))
		usertype.value = uni.getStorageSync('usertype')
		// wx.requestSubscribeMessage({
		// 	tmplIds: moban,
		// 	success(res) {
		// 		uni.login({
		// 			provider: 'weixin', //使用微信登录
		// 			success: function(loginRes) {
		// 				console.log(loginRes, 'loginRes');
		// 			}
		// 		});
		// 	},
		// 	fail(err) {
		// 		console.log("授权失败", err);
		// 	},
		// });
		
	
	})
	let jumpInform = () => {
		uni.switchTab({
			url: "/pages/message/index"
		})
	}
	let jumpConsult = () => {
		uni.navigateTo({
			url: "/homePageOther/environmentalprotection/index"
		})
	}
	let jumpDialogue = () => {
		if (usertype.value == 9) {
			uni.navigateTo({
				url: "/homePageOther/dialogue/index"
			})
		} else {
			uni.navigateTo({
				url: "/homePageOther/enterprisemsgsearch/index"
			})
		}

	}
	let jumpWarning = () => {
		uni.navigateTo({
			url: "/homePageOther/warningcontrol/index"
		})
	}
	let jumpEnterprise = () => {
		// uni.navigateTo({
		// 	url: "/homePageOther/edit-enterprise-msg/index"
		// })
		if (usertype.value == 9) {
			uni.navigateTo({
				url: "/homePageOther/pollutantslicence/index"
			})
			return
		}
		// uni.navigateTo({
		// 	url: "/homePageOther/edit-enterprise-msg/index"
		// })
		uni.navigateTo({
			url: "/homePageOther/enterprise-msg/index"
		})

	}

	// let jumpAuto = () => {
	// 	// if (usertype.value == 9) {
	// 		uni.navigateTo({
	// 			url: "/homePageOther/Autopage/index"
	// 		})
	// 	// } 
	// }
	
	// 已案说法
	let argument = () =>{
		
			uni.navigateTo({
				url:"/homePageOther/caseSpeak/index"
			})
	
	}
	// 自行检测
	let Selftesting = ()=>{
		if(usertype.value==9){
			uni.navigateTo({
				url:"/homePageOther/Selftesting/Selftesting"
			})
		}else{
			uni.navigateTo({
				url:"/homePageOther/Autopage/index"
				
			})
		}
	}
	// 任务派发
	function Taskassignment (){
		console.log(777);
		uni.navigateTo({
			url:"/homePageOther/Taskassignment/Taskassignment"
		})
	}
	// 污染物
	function Antipollutionfacilities (){
		uni.navigateTo({
			url:"/homePageOther/Antipollutionfacilities/Antipollutionfacilities"
		})
	}
	// 古危废
	function Solidhazardouswaste (){
		uni.navigateTo({
			url:"/homePageOther/Solidhazardouswaste/Solidhazardouswaste"
		})
	}
	// 企业代办
	function EnterpriseCorporateAgent (){
		uni.navigateTo({
			url:"/homePageOther/EnterpriseCorporateAgent/EnterpriseCorporateAgent"
		})
	}
	function EnterprisesAntipollutionfacilities (){
		if(usertype.value==9){
			uni.navigateTo({
				url:"/homePageOther/Antipollutionfacilities/Antipollutionfacilities"
			})
			
		}else{
			uni.navigateTo({
				url:"/homePageOther/EnterprisesAntipollutionfacilities/EnterprisesAntipollutionfacilities"
			})
		}
		
	}
</script>

<style lang="scss" scoped>
	.home {
		width: 100vw;
		height: 100vw;
		position: relative;
		padding-top: 506upx;

		.top-bgc {
			position: absolute;
			top: 0;
			width: 100%;
			height: 506upx;
		}

		.scroll-container {
			height: 900rpx;
			width: 100%;
			/* 设置合适的高度 */
			overflow-y: auto;
			/* 启用垂直滚动 */

		}

		.xxx {
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
		}

		.message-wrap {
			padding: 0 25upx 0 21upx;
		}

		.message-one {
			width: 324rpx;
			height: 303rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 76rpx 0rpx #EDF2FF;
			border-radius: 21rpx;
			position: relative;
			margin-top: 4rpx;
		}

		.img {
			width: 104.17rpx;
			height: 104.17rpx;
			position: absolute;
			top: 61rpx;
			left: 118.81rpx;
			right: 108rpx;

			.one {
				width: 104.17rpx;
				height: 104.17rpx;
			}
		}

		.one-text {
			width: 170rpx;
			height: 26rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 28rpx;
			line-height: 26rpx;
			position: absolute;
			bottom: 62.5rpx;
			left: 108.33rpx;
		}

		.one-texts {
			width: 200rpx;
			height: 26rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 28rpx;
			line-height: 26rpx;
			position: absolute;
			bottom: 62.5rpx;
			left: 80.33rpx;
		}


















		// end
		.inform-title-wrap {
			padding: 0 27upx;

			.inform-wrap {
				display: flex;
				align-items: center;
				width: 100%;
				height: 83rpx;
				background: #F5F5FD;
				border-radius: 7rpx;
				margin: 20upx 0 20upx 0;
				padding: 0 32upx 0 22upx;

				.inform-icon {
					width: 68upx;
					height: 33upx;
				}

				.line {
					width: 2rpx;
					height: 27rpx;
					background: #DBDEE4;
					border-radius: 1rpx;
					margin: 0 21upx;
				}

				.inform-now {
					width: 65upx;
					height: 31upx;
					margin-right: 15upx;
				}

				text {

					font-family: Source Han Sans CN;
					font-weight: 500;
					font-size: 29rpx;
					color: #626469;
					flex-grow: 1;

				}

				.right-arrow {
					width: 12upx;
					height: 19upx;
				}
			}
		}


		.location {
			position: absolute;
			left: 63upx;
			top: 100upx;

			image {
				width: 27upx;
				height: 32upx;
				margin-right: 15upx;
			}

			.text {

				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 36rpx;
				color: #FFFFFF;

			}
		}

		.enterprise-msg {
			position: absolute;
			left: 63upx;
			top: 134upx;

			.enterprise-name {
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
			}

			.enterprise-loc {
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				margin-top: 15upx;
			}

			.admin-name {
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				margin-top: 15upx;
			}
		}

		.icon {
			position: absolute;
			left: 63upx;
			top: 330upx;
			width: 65upx;
			height: 24upx;
		}
	}
</style>